import request from '@/config/axios'

// 金料仓库 VO
export interface GoldWarehouseVO {
  id: number
  name: string
  code: string
  type: number // 仓库类型（1：公司仓，2：团队仓，3：个人仓）
  status: number
  remark: string
  createTime: Date
}

// 金料仓库 API
export const GoldWarehouseApi = {
  // 获取启用的金料仓库简单列表
  getGoldWarehouseEnabledSimpleList: async () => {
    return await request.get({ url: `/gold/warehouse/enabled-simple-list` })
  },

  // 获取团队仓库列表
  getTeamWarehouses: async () => {
    return await request.get({ url: `/gold/warehouse/team-warehouses` })
  },

  // 根据团队仓ID获取个人仓列表
  getPersonalWarehousesByTeamId: async (teamWarehouseId: number) => {
    console.log('调用接口 /gold/warehouse/warehouses-by-team，参数:', teamWarehouseId)
    return await request.get({
      url: `/gold/warehouse/warehouses-by-team?teamWarehouseId=${teamWarehouseId}`
    })
  },

  // 根据团队仓ID获取仓库列表
  getWarehousesByTeams: async (teamWarehouseId?: number) => {
    if (teamWarehouseId) {
      return await request.get({ url: `/gold/warehouse/warehouses-by-teams?id=${teamWarehouseId}` })
    } else {
      return await request.get({ url: `/gold/warehouse/warehouses-by-teams` })
    }
  }
}
